<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <link rel="icon" href="/favicon.ico">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vite App</title>
</head>

<body>
  <div id="app"></div>
  <script type="module" src="/src/main.js"></script>
</body>

</html>
<script>
  let { port1, port2 } = new MessageChannel()
  port1.onmessage = function (e) {
    console.log('收到了port2的消息', e)
  }
  port2.onmessage = function (e) {
    console.log('收到了port1的消息', e)
  }
  port1.postMessage('hello');
  port2.postMessage('world')
</script>